﻿using System.Runtime.InteropServices;
using System.Xml.Linq;

namespace Lightray.Hattrick.ChppLib.EntityTypes
{
    [ComVisible(true)]
    public class Region : EntityBase
    {
        #region Properties
        public string Name { get; private set; }
        public Weather Weather { get; private set; }
        public Weather TomorrowForecast { get; private set; }
        #endregion

        protected Region() { } 

        public static Region FromXml(XDocument xml)
        {
            HattrickXmlReader reader = new HattrickXmlReader(xml);
            return new Region()
            {
                ID = reader.ReadNumber("RegionID"),
                DataTime = reader.ReadDate("FetchedDate"),
                Name = reader.ReadString("RegionName"),
                Weather = reader.ReadWeather("WeatherID"),
                TomorrowForecast = reader.ReadWeather("TomorrowWeatherID"),  
            };
        }

        public override string ToString()
        {
            return Name;
        }
    }
}
